﻿// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_PROD_HISTORY_TECHNIC_ITEM
// * CreateDate    : 2012/4/19 16:56:13
// * Creater       : CodeSmith
// * LastChangeDate: 2012/4/19 16:56:13
// * LastChanger   : 2012/4/19 16:56:13
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Prod
{
    /// <summary>
    /// ProdHistoryTechnicItem
    /// </summary>
    public partial class ProdHistoryTechnicItemBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objProdHistoryTechnicItemEntity">Entity</param>
        /// <returns>Entity</returns>
        public static ProdHistoryTechnicItemEntity GetProdHistoryTechnicItem(ProdHistoryTechnicItemEntity objProdHistoryTechnicItemEntity)
        {
            return DataAccess.SelectSingle<ProdHistoryTechnicItemEntity>(objProdHistoryTechnicItemEntity);
        }
        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objProdHistoryTechnicItemEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertProdHistoryTechnicItem(ProdHistoryTechnicItemEntity objProdHistoryTechnicItemEntity)
        {
            return DataAccess.Insert(objProdHistoryTechnicItemEntity);
        }

        public static bool InsertProdHistoryTechnicItem(List<ProdHistoryTechnicItemEntity> objProdHistoryTechnicItemEntityList)
        {
            return DataAccess.Insert(objProdHistoryTechnicItemEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objProdHistoryTechnicItemEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateProdHistoryTechnicItem(ProdHistoryTechnicItemEntity objProdHistoryTechnicItemEntity)
        {
            return DataAccess.Update(objProdHistoryTechnicItemEntity);
        }

        public static bool UpdateProdHistoryTechnicItem(List<ProdHistoryTechnicItemEntity> objProdHistoryTechnicItemEntityList)
        {
            return DataAccess.Update<ProdHistoryTechnicItemEntity>(objProdHistoryTechnicItemEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objProdHistoryTechnicItemEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteProdHistoryTechnicItem(ProdHistoryTechnicItemEntity objProdHistoryTechnicItemEntity)
        {
            return DataAccess.Delete(objProdHistoryTechnicItemEntity);
        }

        public static bool DeleteProdHistoryTechnicItem(List<ProdHistoryTechnicItemEntity> objProdHistoryTechnicItemEntityList)
        {
            return DataAccess.Delete<ProdHistoryTechnicItemEntity>(objProdHistoryTechnicItemEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetProdHistoryTechnicItemAll()
        {
            return DataAccess.SelectAllDataSet<ProdHistoryTechnicItemEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<ProdHistoryTechnicItemEntity> GetProdHistoryTechnicItemAllList()
        {
            return DataAccess.SelectAll<ProdHistoryTechnicItemEntity>();
        }
        #endregion

        #region Functions
        public static DataTable GetDtAllByHistoryTechnicID(string sHistoryTechnicID)
        {
            string sql = @"select phti.*,MWG.GROUP_NAME,PT.TECHNIC_NAME,PT.TECHNIC_CODE,MCI.ITEM_NAME
from PROD_HISTORY_TECHNIC_ITEM phti
left join PROD_TECHNIC pt on phti.TECHNIC_ID=pt.TECHNIC_ID
left join MST_COMMON_ITEM mci on pt.STATION_TYPE=mci.ITEM_TYPE
left join MST_WORKING_GROUP mwg ON phti.GROUP_ID=MWG.GROUP_ID
where phti.HISTORY_TECHNIC_ID='" + sHistoryTechnicID + "' ";
            sql += "order by phti.SEQUENCE ";
            return DataAccess.SelectDataSet(sql).Tables[0];
        }
        #endregion
    }


}

